<template >
  <div v-loading="loading"
    element-loading-text="拼命加载中"
    element-loading-spinner="el-icon-loading"
    element-loading-background="rgba(0, 0, 0, 0.8)" style="height: 500px;">
    <div>
        <!-- <el-button size="mini" type="primary" @click="sendBtn">下发任务</el-button> -->
        <!-- <el-button size="mini" type="primary" @click="changeBtn">修改任务</el-button> -->
        <!-- <el-button size="mini" type="primary" @click="cancelBtn">取消任务</el-button> -->
        <!-- <el-button size="mini" type="primary" @click="infoBtn">获取任务信息</el-button> -->
        <el-button size="mini" type="primary" @click="startWarehousingBtn">启动入库</el-button>
        <!-- <el-button size="mini" type="primary" @click="logoSearchBtn">日志查询</el-button> -->
    </div>
    <div class="ulNameBox" >
        <ul>
            <li>
                <el-select size="mini" v-model="taskType" placeholder="请选择">
                    <el-option
                        v-for="item in options1"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value"
                    >
                    </el-option>
                </el-select>
                <span>任务类型：</span>
            </li>
            <li>
                <el-input
                    ref="rowNo"
                    size="mini"
                    v-model="wmsTaskId"
                    placeholder="请输入内容"
                ></el-input>
                <span>任务ID：</span>
            </li>
            <li>
                <el-input
                    ref="rowNo"
                    size="mini"
                    v-model="palletCode"
                    placeholder="请输入内容"
                ></el-input>
                <span>托盘编码：</span>
            </li>
            <li>
                <el-input
                    ref="rowNo"
                    size="mini"
                    v-model="palletWeight"
                    placeholder="请输入内容"
                ></el-input>
                <span>物料重量：</span>
            </li>
            <li>
                <el-input
                    ref="rowNo"
                    size="mini"
                    v-model="heightValue"
                    placeholder="请输入内容"
                ></el-input>
                <span>物料高度：</span>
            </li>
            <li>
                <el-input
                    ref="rowNo"
                    size="mini"
                    v-model="startCode"
                    placeholder="请输入内容"
                ></el-input>
                <span>开始位置：</span>
            </li>
            <li>
                <el-input
                    ref="rowNo"
                    size="mini"
                    v-model="endCode"
                    placeholder="请输入内容"
                ></el-input>
                <span>结束位置：</span>
            </li>
            <li>
                <el-input
                    ref="rowNo"
                    size="mini"
                    v-model="rowNo"
                    placeholder="请输入内容"
                ></el-input>
                <span>货位分组序号：</span>
            </li>
            <li>
                <el-input
                    ref="rowNo"
                    size="mini"
                    v-model="roadway"
                    placeholder="请输入内容"
                ></el-input>
                <span>巷道：</span>
            </li>
        </ul>
    </div>
    
  </div>
</template>
<script>
import { outBill,logSearch } from "@/utils/api.js"
export default {
  name: "",
  data() {
    return {
        options1: [
        {
          value: "1",
          label: "入库",
        },
        {
          value: "2",
          label: "出库",
        },
        {
          value: "3",
          label: "移库",
        }
      ],
        taskType:'',
        wmsTaskId:'',
        palletCode:'',
        palletWeight:'',
        heightValue:'',
        startCode:'',
        endCode:'',
        rowNo:'',
        roadway:'',
        remark:'',
        info:'',
        times:'',
        value1:'',
        clickAlready:false ,//是否已经点击按钮，防止段时间内多次点击，
        loading:false
    };
  },
  methods: {
    // 下发任务
    sendBtn(){
        // console.log(this.taskType)
        outBill({
            command:1,
            taskType:this.taskType,
            wmsTaskId:this.wmsTaskId,
            palletCode:this.palletCode,
            palletWeight:this.palletWeight,
            palletheight:this.heightValue,
            startCode:this.startCode,
            endCode:this.endCode,
            roadway:this.roadway,
            rowNo:this.rowNo,
            // remark:this.remark,
        }).then((res)=>{
            console.log(res)
            this.info = res.data
        })
        
    },
    // 修改任务
    changeBtn(){
        outBill({
            command:2,
            taskType:this.taskType,
            wmsTaskId:this.wmsTaskId,
            palletCode:this.palletCode,
            palletWeight:this.palletWeight,
            palletheight:this.heightValue,
            startCode:this.startCode,
            endCode:this.endCode,
            roadway:this.roadway,
            rowNo:this.rowNo,
            // remark:this.remark,
        }).then((res)=>{
            console.log(res)
            this.info = res.data
        })
    },
    // 取消任务
    cancelBtn(){
        outBill({
            command:3,
            taskType:this.taskType,
            wmsTaskId:this.wmsTaskId,
            palletCode:this.palletCode,
            palletWeight:this.palletWeight,
            palletheight:this.heightValue,
            startCode:this.startCode,
            endCode:this.endCode,
            roadway:this.roadway,
            rowNo:this.rowNo,
            // remark:this.remark,
        }).then((res)=>{
            console.log(res)
            this.info = res.data
        })
    },
    // 获取任务信息
    infoBtn(){
        outBill({
            command:4,
            taskType:this.taskType,
            wmsTaskId:this.wmsTaskId,
            palletCode:this.palletCode,
            palletWeight:this.palletWeight,
            palletheight:this.heightValue,
            startCode:this.startCode,
            endCode:this.endCode,
            roadway:this.roadway,
            rowNo:this.rowNo,
            // remark:this.remark,
        }).then((res)=>{
            console.log(res)
            this.info = res.data
        })
    },
    // 启动入库
    startWarehousingBtn(){   
        if(this.clickAlready){
            return;
        }
        this.clickAlready = true;
        this.loading=true;
        var that =this;
        outBill({
            command:5,
            taskType:this.taskType,
            wmsTaskId:this.wmsTaskId,
            palletCode:this.palletCode,
            palletWeight:this.palletWeight,
            palletheight:this.palletheight,
            startCode:this.startCode,
            endCode:this.endCode,
            roadway:this.roadway,
            rowNo:this.rowNo,
            // remark:this.remark,
        }).then((res)=>{
            if(res.data.code == 200){
                this.$Alert({
                    title: "成功",
                    message: "成功回库",
                    type: "success"
                    
                });
            }else {
                this.$Alert({
                    title: "失败",
                    message: res.data.data,
                    type: "error"
            });
            }
            this.loading=false;
        });
        //var that = this;
        
        var time = window.setTimeout(()=>{
            this.clickAlready = false;
            window.clearTimeout(time);
        },3000)
    },
    logoSearchBtn(){
        logSearch({
            wmsTaskId:'11'
        }).then((res)=>{
            if(res.data.code == 200){
                this.$Alert({
                    title: "成功",
                    message: res.data.msg,
                    type: "success"
                });
            }else {
                this.$Alert({
                    title: "失败",
                    message: res.data.data,
                    type: "error"
            });
            }
            console.log('日志查询',res)
        })
    }
  }
};
</script>
<style scoped>
.ulNameBox {
    width: 100%;
    margin-top: 10px;
    overflow: hidden;
}
.ulNameBox ul li {
  float: left;
  width: 21%;
  height: 30px;
  line-height: 30px;
  margin-right: 1%;
  margin-bottom: 5px;
  overflow: hidden;
}
.ulNameBox ul li span {
  float: right;
}
.ulNameBox ul li div {
  float: right;
}
.el-input {
    width: 130px;
}
.el-select {
  width: 130px;
}
.infoBox{
    width: 60%;
    margin-top: 50px;
    margin-left: 20%;
}
</style>